/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.clienterestful.bo;

import com.clienterestful.util.RESTFulservice;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import javax.ws.rs.core.MediaType;

public class CitaBO {
    private final String sRecurso="cita";
    private WebResource wrRecurso;
    
    public CitaBO(){
        //obtenemos el recurso de la coneccion al servicio
        this.wrRecurso= (new RESTFulservice()).getWebResource(this.sRecurso);
    }
    public void addCitaXML(Object entity)throws UniformInterfaceException{
        WebResource recurso=this.wrRecurso;
        recurso.type(MediaType.APPLICATION_XML).post(entity);
    }
    public void addCitaJSON(Object cita)throws UniformInterfaceException{
        WebResource recurso=this.wrRecurso;
        recurso.type(MediaType.APPLICATION_JSON).post(cita);
    }
    public void editCitaXML(Object cita)throws UniformInterfaceException{
        WebResource recurso=this.wrRecurso;
        recurso.type(MediaType.APPLICATION_XML).put(cita);
    }
    public void editCitaJSON(Object cita)throws UniformInterfaceException{
        WebResource recurso=this.wrRecurso;
        recurso.type(MediaType.APPLICATION_JSON).put(cita);
    }
   public void deleteCita(String idCita)throws UniformInterfaceException{
       WebResource recurso=this.wrRecurso;
       recurso.path(java.text.MessageFormat.format("{0}", new Object[]{idCita})).delete();
   }
   public <T> T findAllCitasXML(Class<T> responseType) throws UniformInterfaceException{
       WebResource recurso=this.wrRecurso;
       return recurso.accept(MediaType.APPLICATION_XML).get(responseType);
   }
}
